import java.util.Scanner;

/**
 * @author vivi
 * @description
 * @date 2024/5/29
 */
public class demo3 {
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] dp = new int[n + 1];
        for(int i = 0; i <= n; i++)
        {
            dp[i] = 0x3f3f3f3f;
        }
        dp[0] = 0;
        for(int i = 1; i * i <= n; i++)
        {
            for(int j = i * i; j <= n; j++)
            {
                dp[j] = Math.min(dp[j], dp[j - i * i] + 1);
            }
        }
        System.out.println(dp[n]);
    }
}
